package com.lmax.disruptor.custom.group;

import com.lmax.disruptor.custom.demo.Trade;
import com.lmax.disruptor.dsl.Disruptor;

import java.util.concurrent.CountDownLatch;

public class TradePublisher implements Runnable
{
    Disruptor<Trade> disruptor;
    private final CountDownLatch latch;
    private static int count = 1_000; //模拟百万次交易的发生

    public TradePublisher(final Disruptor<Trade> disruptor, final CountDownLatch latch, final int count)
    {
        this.disruptor = disruptor;
        this.latch = latch;
        this.count = count;
    }

    @Override
    public void run()
    {
        TradeEventTranslator translator = new TradeEventTranslator();
        for (int i = 0; i < count; i++)
        {
            System.out.println("producer----" + i);
            disruptor.publishEvent(translator);
        }
//latch.countDown();
    }

}


